﻿using Huirui.Cavan.Core.MyLinq;
using Huirui.Cavan.Core.Persistent;
using Huirui.Cavan.Domain.MainBoundedContext.SearchModule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Huirui.Cavan.Core.Extension;
namespace Huirui.Cavan.Domain.MainBoundedContext.StockModule
{
    public class StockTypeSpecification : ISpecification<StockType, StockTypeSearch>
    {
        #region ISpecification<WareHouse,WareHouseSearch> Members

        public StockTypeSearch SearchParams
        {
            get;
            set;
        }

        #endregion

        #region ISpecification<WareHouse> Members

        public System.Linq.Expressions.Expression<Func<StockType, bool>> Expression
        {
            get
            {
                IQueryBuilder<StockType> queryBuilder = QueryBuilder.Create<StockType>();

                if (SearchParams.IsNotNull())
                {
                    if (SearchParams.Name.IsNotEmpty())
                    {
                        queryBuilder = queryBuilder.Equals(si => si.Name, SearchParams.Name);
                    }
                }

                return queryBuilder.Expression.Expand();


            }
        }

        #endregion
    }
}
